
set(target_name ql_ecs)

file(GLOB_RECURSE SRC_FILES ./src/*)

add_library(${target_name} STATIC ${SRC_FILES})

target_include_directories(ql_ecs PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}/include
    ${QLAYOUT_SDK_DIR}/include
)

find_package(spdlog REQUIRED)
find_package(EnTT REQUIRED)
target_link_libraries(${target_name} PRIVATE spdlog::spdlog)
target_link_libraries(${target_name} PRIVATE EnTT::EnTT)

# 安装配置
install(TARGETS ${target_name}
    EXPORT ql_ecsTargets
    ARCHIVE DESTINATION lib
    PUBLIC_HEADER DESTINATION include
)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
    install(DIRECTORY include/ecs DESTINATION include)
else()
    install(DIRECTORY include/ecs DESTINATION include)
endif()



# 生成配置文件
install(EXPORT ql_ecsTargets
    FILE ql_ecsTargets.cmake
    DESTINATION lib/cmake/ql_ecs
)

include(CMakePackageConfigHelpers)
configure_package_config_file(
    ${CMAKE_CURRENT_SOURCE_DIR}/ql_ecsConfig.cmake.in
    ${CMAKE_CURRENT_BINARY_DIR}/ql_ecsConfig.cmake
    INSTALL_DESTINATION lib/cmake/ql_ecs
)

install(FILES 
    ${CMAKE_CURRENT_BINARY_DIR}/ql_ecsConfig.cmake
    DESTINATION lib/cmake/ql_ecs
)